package lexical;

import java.util.HashMap;

public enum Key {
    IDENFR,
    INTCON,
    STRCON,
    MAINTK,
    CONSTTK,
    INTTK,
    BREAKTK,
    CONTINUETK,
    IFTK,
    ELSETK,
    NOT,
    AND,
    OR,
    WHILETK,
    GETINTTK,
    PRINTFTK,
    RETURNTK,
    PLUS,
    MINU,
    VOIDTK,
    MULT,
    DIV,
    MOD,
    LSS,
    LEQ,
    GRE,
    GEQ,
    EQL,
    NEQ,
    ASSIGN,
    SEMICN,
    COMMA,
    LPARENT,
    RPARENT,
    LBRACK,
    RBRACK,
    LBRACE,
    RBRACE,

    TMP;


    public static final HashMap<String, Key> map = new HashMap<String, Key>() {{
        put("main", Key.MAINTK);
        put("const", Key.CONSTTK);
        put("int", Key.INTTK);
        put("break", Key.BREAKTK);
        put("continue", Key.CONTINUETK);
        put("if", Key.IFTK);
        put("else", Key.ELSETK);
        put("while", Key.WHILETK);
        put("getint", Key.GETINTTK);
        put("printf", Key.PRINTFTK);
        put("return", Key.RETURNTK);
        put("void", Key.VOIDTK);
    }};
    public static Key isReservedWord(String word) {
        return map.getOrDefault(word, Key.IDENFR);
    }
}
